Skip to content

fix: forward Lua version features from selene-lib to CLI crate - #666

Open
roobie wants to merge 1 commit into
Kampfkarren:mainfrom
roobie:main
Open

roobie wants to merge 1 commit into
Kampfkarren:mainfrom
roobie:main

Conversation

@roobie

@roobie roobie commented Apr 1, 2026

Copy link
Copy Markdown

The selene-lib crate defines lua52, lua53, lua54, and luajit as default features (enabling the corresponding full_moon parser features), but the selene CLI crate imports selene-lib with default-features = false and only re-exports the roblox feature. This means cargo install selene and the GitHub release binaries cannot parse Lua 5.2+ syntax (goto/labels), LuaJIT extensions (ULL number suffixes), or \x hex string escapes.

Forward all four Lua version features through the CLI crate and include them in its default feature set, matching selene-lib's own defaults.

Fixes #581

This PR was assisted by AI

The selene-lib crate defines lua52, lua53, lua54, and luajit as default
features (enabling the corresponding full_moon parser features), but the
selene CLI crate imports selene-lib with default-features = false and
only re-exports the roblox feature. This means cargo install selene and
the GitHub release binaries cannot parse Lua 5.2+ syntax (goto/labels),
LuaJIT extensions (ULL number suffixes), or \x hex string escapes.

Forward all four Lua version features through the CLI crate and include
them in its default feature set, matching selene-lib's own defaults.

Fixes Kampfkarren#581

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nurpax

nurpax commented Jun 18, 2026

Copy link
Copy Markdown

I noticed a weird subtlety related to this.

I've sent this PR #646 which fixed the problem for me (the propagation of lua version). However, I now stumbled upon your change and I started wondering why did my change fix the problem for me, when your change looks like it should be required too.

Well, I was building my selene binary with cargo build --release and not with cargo install selene (or running cargo run -p selene). If building selene with cargo build it seems like the defaults are picked for the full workspace which then sets more defaults than the selene/Cargo.toml.

I verified this theory with the below repros:

 # selene.toml
std = "lua53"

-- test.lua
local x = 1 & 2

running cargo run -p selene -- --config selene.toml test.lua fails with

ERROR: lua version lua53 in standard library, but feature for it is not enabled
ERROR: lua version lua52 in standard library, but feature for it is not enabled
error[parse_error]: unexpected character &
  ┌─ test.lua:1:13
  │
1 │ local x = 1 & 2
  │             ^

error[parse_error]: unexpected token `2`
  ┌─ test.lua:1:15
  │
1 │ local x = 1 & 2
  │               ^ unexpected token, this needs to be a statement

but it works fine if I instead do:

cargo build --release
../target/release/selene --config selene.toml test.lua

So IMO both PRs are needed. Mine fixes Lua version inheritance in config files and yours adds the right build time feature enables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using the LuaJIT extension syntax for ULL numbers causes a parse error (despite already being supported?)

2 participants